package cn.fatgod.learn.thymeleaf.ast.model;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;

import java.util.ArrayList;
import java.util.List;

/**
 * 枚举项
 */
public class EnumItem {
    /**
     * 枚举项名称
     */
    private final String name;

    /**
     * 注释
     */
    private final String comment;

    /**
     * 参数列表
     */
    private final List<ArgItem> args;

    private EnumItem(String name, String comment, List<ArgItem> args) {
        this.name = name;
        this.comment = comment;
        this.args = args;
    }


    public static EnumItem create(String name) {
        return create(name, StrUtil.EMPTY, new ArrayList<>());
    }

    public static EnumItem create(String name, String comment) {
        return create(name, comment, new ArrayList<>());
    }

    public static EnumItem create(String name, List<ArgItem> args) {
        return create(name, StrUtil.EMPTY, args);
    }

    public static EnumItem create(String name, String comment, List<ArgItem> args) {
        return new EnumItem(name, comment, CollUtil.isEmpty(args) ? new ArrayList<>() : args);
    }

    public EnumItem addArg(String val) {
        this.args.add(ArgItem.create(val));
        return this;
    }

    public EnumItem addArg(String val, boolean str, String importPath) {
        this.args.add(ArgItem.create(val, str, importPath));
        return this;
    }

    public EnumItem addArg(ArgItem arg) {
        this.args.add(arg);
        return this;
    }

    public EnumItem addArgs(List<ArgItem> args) {
        this.args.addAll(args);
        return this;
    }

    public String getName() {
        return name;
    }

    public String getComment() {
        return comment;
    }

    public List<ArgItem> getArgs() {
        return args;
    }
}